package com.xbongbong.saas.service;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONException;
import com.alibaba.fastjson.JSONObject;
import com.xbongbong.paas.constant.PaasConstant;
import com.xbongbong.paas.domain.entity.ext.OptionalRangeEntity;
import com.xbongbong.paas.domain.entity.ext.PaasFormDataEntityExt;
import com.xbongbong.paas.enums.DelEnum;
import com.xbongbong.paas.enums.OptionalRangeEnum;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.paas.toolbox.wrap.BaseVO;
import com.xbongbong.paas.toolbox.wrap.UserVO;
import com.xbongbong.pro.listbatch.pojo.TeamBatchPojo;
import com.xbongbong.pro.publicgroup.pojo.dto.PublicGroupSeniorDeleteDTO;
import com.xbongbong.pro.publicgroup.pojo.dto.PublicGroupSeniorDetailDTO;
import com.xbongbong.pro.publicgroup.pojo.dto.PublicGroupSeniorFormListDTO;
import com.xbongbong.pro.publicgroup.pojo.dto.PublicGroupSeniorMoveDTO;
import com.xbongbong.pro.publicgroup.pojo.dto.PublicGroupSeniorSaveDTO;
import com.xbongbong.pro.publicgroup.pojo.vo.PublicGroupFormListVO;
import com.xbongbong.pro.publicgroup.pojo.vo.PublicGroupSeniorFormListVO;
import com.xbongbong.pro.publicgroup.pojo.vo.PublicGroupSeniorItemVO;
import com.xbongbong.pro.publicgroup.pojo.vo.PublicGroupSeniorListVO;
import com.xbongbong.saas.domain.entity.PublicGroupSeniorEntity;
import com.xbongbong.sys.domain.entity.DepartmentEntity;
import com.xbongbong.sys.domain.entity.UserEntity;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * @author zhouwq
 * @date 2022/4/14 14:10
 */

public interface PublicGroupSeniorService {


    /**
     * 保存
     * @return
     * @throws
     */
    BaseVO add(PublicGroupSeniorSaveDTO publicGroupSeniorSaveDTO) throws XbbException;

    /**
     * 删除
     * @return
     * @throws
     */
    BaseVO delete(PublicGroupSeniorDeleteDTO publicGroupSeniorDeleteDTO) throws XbbException;


    /**
     * 获取分组详细规则
     * @return
     * @throws
     *
     */
    PublicGroupSeniorItemVO getItem(PublicGroupSeniorDetailDTO publicGroupSeniorDetailDTO) throws XbbException;

    /**
     * 批量更新
     * @return
     */
    BaseVO move(PublicGroupSeniorMoveDTO publicGroupSeniorMoveDTO) throws XbbException;


    /**
     * 获得模板下分组
     * @param publicGroupSeniorDetailDTO
     * @return
     */
    PublicGroupSeniorListVO getByFormId(PublicGroupSeniorDetailDTO publicGroupSeniorDetailDTO) throws XbbException;

    PublicGroupSeniorFormListVO getSeniorFormList(PublicGroupSeniorFormListDTO publicGroupSeniorFormListDTO) throws XbbException;

    PublicGroupFormListVO getFormList(PublicGroupSeniorFormListDTO publicGroupSeniorFormListDTO) throws XbbException;

    Map<Long, PublicGroupSeniorEntity> getPublicGroupMap(Long formId, String corpid);

    void dealId2GroupName(String groupAttr, JSONObject dataJsonObject, Map<Long, PublicGroupSeniorEntity> publicGroupSeniorMap) throws XbbException;

    /**
     * 根据优先级规则处理分组
     * @param corpid
     * @param formId
     * @author lijiangren
     * @date 2022-05-16 09 30
     */
    List<PublicGroupSeniorEntity> getFormListByPriority(String corpid, Long formId) throws XbbException;

    List<PublicGroupSeniorEntity> filterGroupSeniorByAdminScopeRule(List<PublicGroupSeniorEntity> list, UserEntity user);

    List<TeamBatchPojo> publicGroupVerify(String corpid, Integer businessType, Long formId, String oprateTag, UserVO loginUser, List<PaasFormDataEntityExt> list, List<Long> dateIdList);

}
